package com.jian.java.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.jian.java.fallback.MyFallBcak;
import com.jian.java.service.MyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Jiange
 * @create 2021-06-04-20:24
 */
@RestController
public class MyController {
    @Autowired
    private MyService myService;

    @GetMapping("/jian/{id}")
    @SentinelResource(value = "fallback",fallbackClass = {MyFallBcak.class},fallback = "handler")
    public String jian(@PathVariable(value = "id",required = false) int id){
        String s = myService.get();
        if(id ==4){
            throw new RuntimeException("建哥最帅");
        }
        return s;
    }
}
